<template>
  <div>
    <el-card class="box-card">
      <el-row>
        <el-col :span="5" class="labClass">
          <div class="grid-content bg-purple">
            <span>供应商名称:</span>
          </div>
        </el-col>
        <el-col :span="16">
          <div class="grid-content bg-purple-light">
            <el-input v-model="supplierName" placeholder="供应商名称"></el-input>
          </div>
        </el-col>
        <el-col :span="3" class="labClass">
          <div class="grid-content bg-purple">
          </div>
        </el-col>
      </el-row>

      <p/>
      <el-row>
        <el-col :span="5" class="labClass">
          <div class="grid-content bg-purple">
            <span>负责人:</span>
          </div>
        </el-col>
        <el-col :span="16">
          <div class="grid-content bg-purple-light">
            <el-input v-model="supplierUser" placeholder="负责人"></el-input>
          </div>
        </el-col>
        <el-col :span="3" class="labClass">
          <div class="grid-content bg-purple">
          </div>
        </el-col>
      </el-row>
      <p/>

      <p/>
      <el-row>
        <el-col :span="5" class="labClass">
          <div class="grid-content bg-purple">
            <span>负责人电话:</span>
          </div>
        </el-col>
        <el-col :span="16">
          <div class="grid-content bg-purple-light">
            <el-input v-model="supplierPhone" placeholder="负责人电话"></el-input>
          </div>
        </el-col>
        <el-col :span="3" class="labClass">
          <div class="grid-content bg-purple">
          </div>
        </el-col>
      </el-row>
      <p/>

      <p/>
      <el-row>
        <el-col :span="5" class="labClass">
          <div class="grid-content bg-purple">
            <span>供应商地址:</span>
          </div>
        </el-col>
        <el-col :span="16">
          <div class="grid-content bg-purple-light">
            <el-input v-model="supplierAddress" placeholder="供应商地址"></el-input>
          </div>
        </el-col>
        <el-col :span="3" class="labClass">
          <div class="grid-content bg-purple">
          </div>
        </el-col>
      </el-row>
      <p/>

      <p/>
      <el-row>
        <el-col :span="5" class="labClass">
          <div class="grid-content bg-purple">
            <span>经营范围:</span>
          </div>
        </el-col>
        <el-col :span="16">
          <div class="grid-content bg-purple-light">
            <el-input v-model="supplierScope" type="textarea" :rows="3" placeholder="经营范围"></el-input>
          </div>
        </el-col>
        <el-col :span="3" class="labClass">
          <div class="grid-content bg-purple">
          </div>
        </el-col>
      </el-row>
      <p/>

      <el-button type="success" @click="add">添加</el-button>
    </el-card>

  </div>
</template>

<script>
export default {
  name: "addSupplier",
  data() {
    return {
      supplierName: '',
      supplierUser: '',
      supplierPhone: '',
      supplierAddress: '',
      supplierScope: ''
    }
  },
  methods: {
    add() {
      if (this.supplierName == '' || this.supplierUser == ''
          || this.supplierPhone == '' || this.supplierAddress == ''
          || this.supplierScope == '') {
        this.$message.error('信息不能有空')
      } else {
        let formData = new FormData()
        formData.append("supplierName", this.supplierName)
        formData.append("supplierUser", this.supplierUser)
        formData.append("supplierPhone", this.supplierPhone)
        formData.append("supplierAddress", this.supplierAddress)
        formData.append("supplierScope", this.supplierScope)
        this.$axios.post('drp/supplier/addSupplier', formData).then(
            r => {
              if (r.data == 'ok') {
                this.$message.success('添加成功')
                location.href = "/index"
              }
            }
        )
      }
    }
  }
}
</script>

<style scoped>

</style>